Change in openvpn[master]: push: Fix conversion issues related to timeout in send_auth_pending_m...
A message that is not in the archive (sent off-list or not yet received): gerrit.1761063820000.Icc31b7fa0da86220df45552aecc15dc6c769cd54@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1293?usp=email
to review the following change.
Change subject: push: Fix conversion issues related to timeout in send_auth_pending_messages
......................................................................
push: Fix conversion issues related to timeout in send_auth_pending_messages
Add additional checking to make sure that the required casts are safe.
---
M src/openvpn/push.c
M src/openvpn/ssl_verify.c
2 files changed, 15 insertions(+), 19 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1293/1
src/openvpn/push.c +11 -6
@@ -429,11 +429,6 @@gc_free (&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -bool send_auth_pending_messages (struct tls_multi *tls_multi,struct tls_session *session,const char *extra,unsigned int timeout)
@@ -449,7 +444,12 @@/* Calculate the maximum timeout and subtract the time we already waited */ unsigned int max_timeout =max_uint (tls_multi->opt.renegotiate_seconds /2 , tls_multi->opt.handshake_window); - max_timeout = max_timeout - (now - ks->initial); +time_t time_elapsed = now - ks->initial; +if (time_elapsed <0 || time_elapsed >= (time_t )max_timeout) + { +return false; + } + max_timeout -= (unsigned int )time_elapsed; timeout =min_uint (max_timeout, timeout);struct gc_arena gc =gc_new ();
@@ -734,6 +734,11 @@return true; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif +static bool send_push_options (struct context *c,struct buffer *buf,struct push_list *push_list,int safe_cap,bool *push_sent,bool *multi_push)
src/openvpn/ssl_verify.c +4 -13
@@ -874,11 +874,6 @@return supported; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -/** * Checks if the deferred state should also send auth pending * request to the client. Also removes the auth_pending control file
@@ -915,8 +910,9 @@buf_chomp (iv_buf);buf_chomp (extra_buf); + errno =0 ;long timeout =strtol (BSTR (timeout_buf),NULL ,10 ); -if (timeout ==0 ) +if (timeout <=0 || timeout >UINT_MAX || errno) {msg (M_WARN ,"could not parse auth pending file timeout" );buffer_list_free (lines);
@@ -933,14 +929,13 @@ pending_method);auth_set_client_reason (multi, buf);msg (M_INFO , -"Client does not supported auth pending method " -"'%s'" , +"Client does not supported auth pending method '%s'" , pending_method); ret = false; }else { -send_auth_pending_messages (multi, session,BSTR (extra_buf), timeout); +send_auth_pending_messages (multi, session,BSTR (extra_buf), (unsigned int )timeout); } }
@@ -950,10 +945,6 @@return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -/** * Removes auth_pending and auth_control files from file system * and key_state structure
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1293?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icc31b7fa0da86220df45552aecc15dc6c769cd54
Gerrit-Change-Number: 1293
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1293?usp=email )
Change subject: push: Fix conversion issues related to timeout in send_auth_pending_messages
......................................................................
Patch Set 5: Code-Review-1
(2 comments)
Patchset:
PS5:
Not sure I understand all the implications. It would be good if @[email protected]... had a look.
File src/openvpn/push.c:
http://gerrit.openvpn.net/c/openvpn/+/1293/comment/0f14fa70_d0079f91?usp=email :
PS5, Line 451: }
I'm a bit unsure about that. In the (unlikely) case of time_elapsed > max_timeout (not sure if this could happen, but maybe if the userland process happens to be busy with ill-behaved scripts?) then we'll not do any AUTH_PENDING at all? Or am I misreading this?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1293?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icc31b7fa0da86220df45552aecc15dc6c769cd54
Gerrit-Change-Number: 1293
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 17 Nov 2025 07:59:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: cron2, plaisthos.
flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1293?usp=email )
Change subject: push: Fix conversion issues related to timeout in send_auth_pending_messages
......................................................................
Patch Set 6:
(1 comment)
File src/openvpn/push.c:
http://gerrit.openvpn.net/c/openvpn/+/1293/comment/9d217d86_9a244d8c?usp=email :
PS5, Line 451: }
Quoted 1 line
I'm a bit unsure about that. […]
But isn't that correct? In that case "max_timeout" has already expired, so shouldn't we fail?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1293?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icc31b7fa0da86220df45552aecc15dc6c769cd54
Gerrit-Change-Number: 1293
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Thu, 20 Nov 2025 14:42:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Attention is currently required from: cron2, flichtenheld.
plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1293?usp=email )
Change subject: push: Fix conversion issues related to timeout in send_auth_pending_messages
......................................................................
Patch Set 9:
(1 comment)
File src/openvpn/push.c:
http://gerrit.openvpn.net/c/openvpn/+/1293/comment/1ede80cb_484f24b6?usp=email :
PS5, Line 451: }
Quoted 1 line
But isn't that correct? In that case "
max_timeout" has already expired, so shouldn't we fail?
Since this return value is only what the management interface gets back, it is probably okay to return false here.
I don't think we need time_elapsed < 0 here since that now < ks->inital is something that should never happen and checking for it here might be more confusing than good.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1293?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icc31b7fa0da86220df45552aecc15dc6c769cd54
Gerrit-Change-Number: 1293
Gerrit-PatchSet: 9
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 21 Jan 2026 12:32:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
Attention is currently required from: cron2, flichtenheld.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1293?usp=email
to look at the new patch set (#10).
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: push: Fix conversion issues related to timeout in send_auth_pending_messages
......................................................................
push: Fix conversion issues related to timeout in send_auth_pending_messages
Add additional checking to make sure that the required casts are safe.
---
M src/openvpn/push.c
M src/openvpn/ssl_verify.c
2 files changed, 13 insertions(+), 7 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1293/10
src/openvpn/push.c +11 -6
@@ -429,11 +429,6 @@gc_free (&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -bool send_auth_pending_messages (struct tls_multi *tls_multi,struct tls_session *session,const char *extra,unsigned int timeout)
@@ -449,7 +444,12 @@/* Calculate the maximum timeout and subtract the time we already waited */ unsigned int max_timeout =max_uint (tls_multi->opt.renegotiate_seconds /2 , tls_multi->opt.handshake_window); - max_timeout = max_timeout - (now - ks->initial); +time_t time_elapsed = now - ks->initial; +if (time_elapsed <0 || time_elapsed >= (time_t )max_timeout) + { +return false; + } + max_timeout -= (unsigned int )time_elapsed; timeout =min_uint (max_timeout, timeout);struct gc_arena gc =gc_new ();
@@ -738,6 +738,11 @@return true; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif +static bool send_push_options (struct context *c,struct buffer *buf,struct push_list *push_list,int safe_cap,bool *push_sent,bool *multi_push)
src/openvpn/ssl_verify.c +2 -1
@@ -911,8 +911,9 @@buf_chomp (iv_buf);buf_chomp (extra_buf); + errno =0 ;long timeout =strtol (BSTR (timeout_buf),NULL ,10 ); -if (timeout <=0 ) +if (timeout <=0 || timeout >UINT_MAX || errno) {msg (M_WARN ,"could not parse auth pending file timeout" );buffer_list_free (lines);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1293?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icc31b7fa0da86220df45552aecc15dc6c769cd54
Gerrit-Change-Number: 1293
Gerrit-PatchSet: 10
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>